<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/admin/common.jsp"%>
<% String param = request.getParameter("newstype"); 
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=basePath %>admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>admin/css/llcss.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<%=basePath %>js/jquery/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=basePath %>admin/js/common.js"></script>
<script type="text/javascript" src="<%=basePath %>admin/js/hd_ll.js"></script>
<script src="<%=basePath%>admin/js/format.js" type="text/javascript"></script>
<script type="text/javascript">
function goToPage(pageno,restype){
	var type = $(".select_down").val();
	var resname = $("#resName").val();
	$.ajax({
		url:'<%=basePath %>resource/list',
		type:'post',
		data:{
			pagesize:6,
			pageno:pageno,
			restype:type,
			resName:resname
		},
		success:function(data){ 
			var list = data.records;
			$(".pwsj_right_byq_divbox").empty();
			for (var i = 0; i < list.length; i++) {
				var content = 
				'<ul class="byq_cont_ul">'+
				'<li style="width:8%;">'+(i+1)+'</li>'+
				'<li style="width:16%;">'+list[i].resname+'</li>'+
				'<li style="width:10%;">'+new Date(list[i].publishtime)
				.format("yyyy-MM-dd")+'</li>'+
				'<li style="width:8%;">'+(list[i].source==null?"未知":list[i].source)+'</li>'+
				'<li style="width:16%;">'+(list[i].downloadurl==null?"":list[i].downloadurl)+'</li>'+
				'<li style="width:26%">'+(list[i].describe==null?"":list[i].describe)+'</li>'+
				'<li style="width:14%;border-right: none;">'+
				'<a href="<%=basePath %>admin/web/resource/modifynews.jsp?resid='+list[i].resid+'" class="detail_a_addlines">修改</a>'+
				'<a href="javascript:deleteres('+list[i].resid+')" class="detail_a_addlines">删除</a>'+
				'</li>'+
				'</ul>';
				$(".pwsj_right_byq_divbox").append(content);
			}
			
			pageList(data,type);
		}
	});
}

function deleteres(resid){
	pwtzconfirm("确定要删除？",function(){
		$.ajax({
			url : contextPath+'resource/delete',
			type : 'post',
			data : {
				resid : resid
			},
			success : function(data){
				alert(data==1? "删除成功":"删除失败");
				if(data==1)
					goToPage(1,0);
			}
		});
	})
}


$(function(){
	var parameter = '<%=param%>';
	$.ajax({
		url:'<%=basePath %>restype/list',
		type:'post',
		sync:false,
		success:function(data){
			$(".select_down").empty();
			for (var i = 0; i < data.length; i++) {
				if(parameter==data[i].typeId && parameter!=""){
				var content='<option value ="'+data[i].typeId+'"  selected="selected">'+data[i].typeName+'</option>';
				}
				else{
				var content='<option value ="'+data[i].typeId+'" >'+data[i].typeName+'</option>';
				}
				$(".select_down").append(content);
			}
			goToPage(1,$(".select_down").val());
		}
	});
});

function toAddPage(){
	var type = $(".select_down").val();
	location.href='<%=basePath %>admin/web/resource/insertnews.jsp?type='+type;
}
</script>
<title>资源列表</title> 
</head>
<body bgcolor="white">
	<%@ include file="/admin/head.jsp"%>
	<div class="pwsj_cont_box">
	<%@ include file="/admin/left.jsp"%>
	<!-- 右侧内容_begin -->
	<div class="pwsj_cont_right_box" style="width:79%;" >
		<!-- 变压器_begin -->
		<div class="pwsj_right_byq">
			<div class="pwsj_right_byq_position">
			<a class="position" href="<%=basePath %>admin/index.jsp">配网数据</a>&gt;
			<a class="position" href="<%=basePath %>admin/web/resource/newslist.jsp">资源管理</a>
		</div>
			<!-- 变压器列表查询条件_begin -->
			<form action="" method="" type="" class="pwsj_byq_choose_form">
				<div class="pwsj_byq_choose">
					<div class='left'>
					
				<select class="select_down"  onchange="goToPage(1,0)" >
				</select>
				
				<input class="btn" type="button" value="添加" onclick="toAddPage()" />
						
						
						<!-- <input class="btn" type="button" value="单线图" /> -->
					</div>
					<div class='right'>
						<input type="text" id="resName" name="resName" class="keywords" placeholder="请输入标题搜索" />
						<input class="submit" type="button" onclick="goToPage(1)" value="搜索" />
					</div>
					<div class="clear"></div>
				</div>
			</form>
			<!-- 变压器列表查询条件_end -->

			<!-- 变压器列表查询结果_begin -->
			<div class="pwsj_right_byq_cont_title">
				<!-- 标题_begin -->
				<ul class="byq_title_ul">
				    
					<li style="width:8%;">序号</li>
					<li style="width:16%;">标题</li>
					<li style="width:10%;">发布时间</li>
					<li style="width:8%;">来源</li>
					<li style="width:16%;">下载地址</li>
					<li style="width:26%;">内容简述</li>
					<li style="width:14%;">操作</li>
				</ul>
				<!-- 标题_end -->
				<!-- 结果_begin -->
				<div class="pwsj_right_byq_divbox">
				</div>				
				<!-- 结果_end -->
			</div>
			<!-- 变压器列表查询结果_end -->

		
					<div class="page">
			            <a href="#">首页</a>
			            <a href="#">上一页</a>
			            <a class="intro" href="#">1</a>
			            <a href="#">下一页</a>
			            <a href="#">末页</a>
	    			</div>
			
		</div>	
		<!-- 变压器_end -->
	</div>
	<!-- 右侧内容_end -->
	<div class="clear"></div><!-- 清除左右浮动 -->

	</div>
	<!--main end-->
<%@ include file="/admin/foot.jsp"%>
</body>
</html>